package com.yowasa.xiuxian.engine.travel.adventure;

import com.google.common.collect.Sets;
import com.yowasa.xiuxian.engine.CommonEngine;
import com.yowasa.xiuxian.engine.item.ItemInterface;
import com.yowasa.xiuxian.engine.travel.AdventureInterface;
import com.yowasa.xiuxian.entity.bo.user.UserBO;
import com.yowasa.xiuxian.entity.enums.MapEnum;
import com.yowasa.xiuxian.entity.enums.QualityEnum;
import com.yowasa.xiuxian.entity.enums.RefreshType;
import com.yowasa.xiuxian.entity.po.XiuxianTransactPO;
import com.yowasa.xiuxian.mapper.XiuxianTransactMapper;
import com.yowasa.xiuxian.service.helper.ResourceHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Set;

/**
 * 金陵大厨 一次刷新仅能被触发一次
 * 上架一个鲜香锅巴
 */
@Component
public class JinLingDaChu implements AdventureInterface {

    @Autowired
    private XiuxianTransactMapper xiuxianTransactMapper;
    @Autowired
    private ResourceHelper resourceHelper;

    @Override
    public Set<MapEnum> limitMaps() {
        //璃月港
        return Sets.newHashSet(MapEnum.LI_YUE_GANG);
    }

    public boolean limitCheck(UserBO user) {
        return resourceHelper.checkHaveResource(user.getGuildId(), this.getClass().getName(), RefreshType.JIU_XING);
    }

    @Override
    public String exec(UserBO user) {
        resourceHelper.useResource(user.getGuildId(), this.getClass().getName());
        String msg = "你在此地游历时听闻万民堂的大厨香菱出手了,做了一道鲜香锅巴,现于交易行拍卖";
        ItemInterface item = CommonEngine.ITEM_MAP.get("鲜香锅巴");
        XiuxianTransactPO xiuxianTransact = new XiuxianTransactPO();
        xiuxianTransact.setStatus(1);
        xiuxianTransact.setItemNum(1);
        xiuxianTransact.setItemName(item.getName());
        xiuxianTransact.setAccountId(0L);
        xiuxianTransact.setItemPrice(10000);
        xiuxianTransact.setItemType(item.getType().getId());
        xiuxianTransact.setItemDesc(item.desc());
        xiuxianTransact.setItemAttr(item.attr(QualityEnum.LIANG));
        xiuxianTransact.setNowPrice(10000);
        xiuxianTransact.setNowAccount(0L);

        xiuxianTransactMapper.insert(xiuxianTransact);
        return msg;
    }

}
